In [1]:
import os
from datetime import datetime
from smdc_perftests.performance_tests import test_scripts
# the test_scripts module contains the function
# run performance tests which runs all the performance tests on a dataset

# in this example we will use the esa cci dataset class
from smdc_perftests.datasets.esa_cci import ESACCI_netcdf
from smdc_perftests import helper

In [2]:
#init the esa cci dataset
fname = os.path.join("/media", "sf_H", "Development", "python", 
                     "workspace", 
                     "SMDC", "SMDC_perftests", "tests", "test_data",
                     "ESACCI-2Images.nc")
# only read the sm variable for this testrun
ds = ESACCI_netcdf(fname, variables=['sm'])
# get the testname from the filename
testname = os.path.splitext(os.path.split(fname)[1])[0]

# generate a date range list using the helper function
# in this example this does not make a lot of sense
date_range_list = helper.generate_date_list(datetime(2013, 11, 30), 
                                            datetime(2013, 12, 1), 
                                            n=50)

# set a directory into which to save the results
# in this case the the tests folder in the home directory
res_dir = "/home/pydev/tests/"
# run the performance tests using the grid point indices from
# the dataset grid, the generated date_range_list and gpi read percentage
# of 0.1 percent and only one repeat
test_scripts.run_performance_tests(testname, ds, res_dir, 
                                   gpi_list=ds.grid.land_ind,
                                   date_range_list=date_range_list,
                                   gpi_read_perc=0.1,
                                   repeats=1)


/media/sf_H/Development/python/workspace/SMDC/SMDC_perftests/smdc_perftests/datasets/esa_cci.py:89: UserWarning: endian-ness of dtype and endian kwarg do not match, using endian kwarg
  self.ds = nc.Dataset(fname)
/home/pydev/.virtualenvs/smdc-perftest/local/lib/python2.7/site-packages/numpy/core/_methods.py:83: RuntimeWarning: Degrees of freedom <= 0 for slice
  warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning)
reading 245 out of 244243 time series
reading 1 out of 50 dates
reading 1 out of 50 dates
/home/pydev/.virtualenvs/smdc-perftest/local/lib/python2.7/site-packages/numpy/core/_methods.py:117: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)

This creates the following files named using the name given to the test and the name of the test function that was run.


In [3]:
!ls /home/pydev/tests


ESACCI-2Images_test-rand-avg-img.nc    ESACCI-2Images_test-rand-gpi.nc
ESACCI-2Images_test-rand-daily-img.nc

Visualization of the results


In [4]:
%matplotlib inline
import glob
import smdc_perftests.performance_tests.analyze as analyze

# get all the files in the results folder
fs = glob.glob(os.path.join(res_dir, "*.nc"))
df = analyze.prep_results(fs)
# this returnes the mean times at the moment
print df
# and makes a very simple bar plot
ax = analyze.bar_plot(df)


                                       means
ESACCI-2Images_test-rand-avg-img    0.094640
ESACCI-2Images_test-rand-gpi        0.106500
ESACCI-2Images_test-rand-daily-img  0.074244

In [ ]: